#!/usr/bin/env python
import cherrypy
#from cherrypy.lib.sessions import *
#from cherrypy import tools
#from cherrypy import sessions 
from genshi.template import TemplateLoader


class Conf:
	PATH_BASE='/var/www/bsd.jdweb.com'
	PATH_TPL=PATH_BASE+'/tpl'
	PATH_HTDOC=PATH_BASE+'/htdocs'

class Proj:
	tpl_loader = TemplateLoader(Conf.PATH_TPL, auto_reload=True) 
	def HTML(cls, tpl_path, **kwds):
		tpl = cls.tpl_loader.load(tpl_path)
		return tpl.generate( **kwds ).render( method='html', encoding='utf-8')

	def XMLSimple(cls, **kwds):
		tpl = cls.tpl_loader.load('simple_return.xml')
		return tpl.generate( **kwds ).render( method='xml', encoding='utf-8')
	
	def Handle_ProjError(cls, status, message, traceback, version ):
		return cls.HTML('admin/error.html', errmsg=message)

	HTML=classmethod(HTML)
	XMLSimple=classmethod(XMLSimple)
	Handle_ProjError=classmethod(Handle_ProjError)
	#session=cherrypy.session


if __name__ == '__main__':
	import sys
	for p in sys.path:
		print p
	import inspect
	mems = inspect.getmembers(Proj)
	for m in mems:
		print m

